home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / library / help / tcl / files / open < prev    next >
Encoding:
Text File  |  1993-10-26  |  4.6 KB  |  101 lines  |  [TEXT/$Tcl]

  1.  
  2.           open fileName ?access? ?permissions?
  3.  
  4.  
  5.      DESCRIPTION
  6.           This command opens a file and returns an identifier that may
  7.           be  used  in future invocations of commands like read, puts,
  8.           and close.  FileName gives the name of the file to open;  if
  9.           it  starts with a tilde then tilde substitution is performed
  10.           as described for Tcl_TildeSubst.  If the first character  of
  11.           fileName  is ``|'' then the remaining characters of fileName
  12.           are treated as a command pipeline to  invoke,  in  the  same
  13.           style as for exec.  In this case, the identifier returned by
  14.           open may be used to write to the  command's  input  pipe  or
  15.           read from its output pipe.
  16.  
  17.           The access argument indicates the way in which the file  (or
  18.           command pipeline) is to be accessed.  It may take two forms,
  19.           either a string in the form that  would  be  passed  to  the
  20.           fopen library procedure or a list of POSIX access flags.  It
  21.           defaults to ``r''.  In the first form access may have any of
  22.           the following values:
  23.  
  24.           r              Open the file for reading only; the file must
  25.                          already exist.
  26.  
  27.           r+             Open the file for both reading  and  writing;
  28.                          the file must already exist.
  29.  
  30.           w              Open the file for writing only.  Truncate  it
  31.                          if  it exists.  If it doesn't exist, create a
  32.                          new file.
  33.  
  34.           w+             Open the file for reading and writing.  Trun-
  35.                          cate  it  if it exists.  If it doesn't exist,
  36.                          create a new file.
  37.  
  38.           a              Open the file for  writing  only.   The  file
  39.                          must  already  exist,  and  the file is posi-
  40.                          tioned so that new data is  appended  to  the
  41.                          file.
  42.  
  43.           a+             Open the file for reading  and  writing.   If
  44.                          the  file  doesn't  exist, create a new empty
  45.                          file.  Set the initial  access  position   to
  46.                          the end of the file.
  47.  
  48.           In the second form, access consists of a list of any of  the
  49.           following  flags, all of which have the standard POSIX mean-
  50.           ings.  One of the flags must be  either  RDONLY,  WRONLY  or
  51.           RDWR.
  52.  
  53.           RDONLY         Open the file for reading only.
  54.  
  55.           WRONLY         Open the file for writing only.
  56.  
  57.           RDWR           Open the file for both reading and writing.
  58.  
  59.           APPEND         Set the file pointer to the end of  the  file
  60.                          prior to each write.
  61.  
  62.           CREAT          Create the file if it doesn't  already  exist
  63.                          (without  this  flag  it  is an error for the
  64.                          file not to exist).
  65.  
  66.           EXCL           If CREAT  is  specified  also,  an  error  is
  67.                          returned if the file already exists.
  68.  
  69.           NOCTTY         If the file is a terminal device,  this  flag
  70.                          prevents  the file from becoming the control-
  71.                          ling terminal of the process.
  72.  
  73.           NONBLOCK       Prevents  the  process  from  blocking  while
  74.                          opening  the file.  For details refer to your
  75.                          system  documentation  on  the  open   system
  76.                          call's O_NONBLOCK flag.
  77.  
  78.           TRUNC          If the file exists it is  truncated  to  zero
  79.                          length.
  80.  
  81.           If a new file is created as part of opening it,  permissions
  82.           (an integer) is used to set the permissions for the new file
  83.           in conjunction with the process's file mode  creation  mask.
  84.           Permissions defaults to 0666.
  85.  
  86.           If a file is opened for both reading and writing  then  seek
  87.           must  be  invoked  between a read and a write, or vice versa
  88.           (this restriction does not apply to command pipelines opened
  89.           with  open).  When fileName specifies a command pipeline and
  90.           a write-only access is used, then standard output  from  the
  91.           pipeline  is  directed to the current standard output unless
  92.           overridden by the command.  When fileName specifies  a  com-
  93.           mand  pipeline and a read-only access is used, then standard
  94.           input from the pipeline is taken from the  current  standard
  95.           input unless overridden by the command.
  96.  
  97.  
  98.      KEYWORDS
  99.           access mode, append,  controlling  terminal,  create,  file,
  100.           non-blocking, open, permissions, pipeline, process
  101.